// src/router/index.js
import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/Login.vue';
import Register from '../views/Register.vue';
import MainLayout from '../views/MainLayout.vue';

const routes = [
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },
    {
        path: '/main',
        component: MainLayout,
        children: [
            {
                path: 'companies',
                name: 'CompanyList',
                component: () => import('../views/CompanyList.vue')
            },
            {
                path: 'port',
                name: 'PortManagement',
                component: () => import('../views/PortManagement.vue')
            },
            {
                path: 'import-orders',
                name: 'ImportOrders',
                component: () => import('../views/ImportOrders.vue')
            },
            {
                path: 'export-orders',
                name: 'ExportOrders',
                component: () => import('../views/ExportOrders.vue')
            },
            {
                path: 'warehouse',
                name: 'Warehouse',
                component: () => import('../views/Warehouse.vue')
            },
            {
                path: 'fees',
                name: 'Fees',
                component: () => import('../views/Fees.vue')
            }
        ]
    },
    {
        path: '/:catchAll(.*)',
        redirect: '/login'
    }
];

const router = createRouter({
    history: createWebHistory(),
    routes
});

export default router;
